package com.ruoyi.project.newhope.data.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.newhope.data.domain.EchartsVO;
import com.ruoyi.project.newhope.data.domain.NewHopeData;
import com.ruoyi.project.newhope.data.service.INewHopeDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 数据查询Controller
 *
 * @author ruoyi
 * @date 2021-02-08
 */
@Controller
@RequestMapping("/api/newhope/data")
public class DataController  extends BaseController {

    @Autowired
    private INewHopeDataService newHopeInfraredDevice;

    /**
     * 查询数据列表
     */
    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo list(NewHopeData newHopeData) {
        startPage();
        List<NewHopeData> list = newHopeInfraredDevice.selectNewHopeDataList(newHopeData);
        return getDataTable(list);
    }

    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(@RequestBody NewHopeData newHopeData)
    {
        List<NewHopeData> list = newHopeInfraredDevice.selectNewHopeDataList(newHopeData);
        ExcelUtil<NewHopeData> util = new ExcelUtil<>(NewHopeData.class);
        return util.exportExcel(list, "检测数据");
    }

    @PostMapping("/echartsData")
    @ResponseBody
    public AjaxResult echartsData(@RequestBody NewHopeData newHopeData)
    {
        List<EchartsVO> result = newHopeInfraredDevice.echartsData(newHopeData);
        return AjaxResult.success(result);
    }
}
